package com.api.shopapi.service.impl;

import com.api.shopapi.entity.DeviceTogWatch;
import com.api.shopapi.entity.dto.DeviceTogWatchDTO;
import com.api.shopapi.mapper.DeviceTogWatchMapper;
import com.api.shopapi.service.DeviceTogWatchService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("DeviceTogWatchServiceImplOne")
public class DeviceTogWatchServiceImpl  implements DeviceTogWatchService {

    @Autowired
    private DeviceTogWatchMapper deviceTogWatchMapper;



    @Override
    public int insert(DeviceTogWatch deviceTogWatch) {
        return deviceTogWatchMapper.insert(deviceTogWatch);
    }

    @Override
    public int update(DeviceTogWatch deviceTogWatch) {
        return deviceTogWatchMapper.update(deviceTogWatch);
    }

    @Override
    public DeviceTogWatch getByDeviceTogWatchCode(String deviceTogWatchCode) {
        return deviceTogWatchMapper.getByDeviceTogWatchCode(deviceTogWatchCode);
    }

    @Override
    public DeviceTogWatch getByUserCode(String userCode) {
        return deviceTogWatchMapper.getByUserCode(userCode);
    }

    @Override
    public DeviceTogWatch getByImei(String imei) {
        return deviceTogWatchMapper.getByImei(imei);
    }

    @Override
    public int deleteByUserCode(String userCode) {
        return deviceTogWatchMapper.deleteByUserCode(userCode);
    }

    @Override
    public PageInfo<DeviceTogWatchDTO> getPage(int pageIndex, int pageSize, String phone, String imei) {
        PageHelper.startPage(pageIndex,pageSize);
        List<DeviceTogWatchDTO> deviceTogWatchDTOList = deviceTogWatchMapper.getPage(phone, imei);
        return new PageInfo<>(deviceTogWatchDTOList);
    }
}
